public class Singletontest06 {
    static {
        System.out.println("双重检测!");
    }

    public static void main(String[] args) throws Exception{
        Singletion06 instance =  Singletion06.getInstance();
        Singletion06 instance2 = Singletion06.getInstance();
        System.out.println(instance == instance2);
        System.out.println(instance.hashCode());
        System.out.println(instance2.hashCode());
    }
}
class Singletion06{
    private static volatile Singletion06 instance;
    private Singletion06(){

    }
    public static Singletion06 getInstance(){
        if(instance==null){
            synchronized (Singletion06.class){
                if (instance==null){
                    instance=new Singletion06();
                }
            }
        }
        return instance;
    }
}